// 引入封装的axios
import axios from '@/utils/myaxios.js'

// 登陆
export const userlogin = function (data) {
  return axios({
    url: '/login',
    method: 'post',
    data
  })
}

// 注册
export const userRegister = function (data) {
  return axios({
    method: 'post',
    url: '/register',
    data
  })
}

// 获取当前用户详情
export const getUserInfo = function (id) {
  return axios({
    // 一定要注意，参数是路由参数
    url: `/user/${id}`,
    headers: { Authorization: localStorage.getItem('toutiao_59_token') }
  })
}

// 编辑用户信息
export const updateUserInfo = function (id, data) {
  return axios({
    method: 'post',
    url: `/user_update/${id}`,
    data
  })
}

// 关注用户
export const followUser = function (id) {
  return axios({
    url: '/user_follows/' + id
  })
}

// 取消关注用户
export const unfollowUser = function (id) {
  return axios({
    url: '/user_unfollow/' + id
  })
}


// 获取当前用户的关注列表
export const getUserFollows = function () {
  return axios({
    url: `/user_follows`,
  })
}

// 获取当前用户的关注列表
export const getUserStars = function () {
  return axios({
    url: `/user_star`,
  })
}